bpf, x86: Fix signed 32-bit div/mod in the i386 JIT#12801
Closed
kernel-patches-daemon-bpf[bot] wants to merge 1 commit into
Closed
bpf, x86: Fix signed 32-bit div/mod in the i386 JIT#12801kernel-patches-daemon-bpf[bot] wants to merge 1 commit into
kernel-patches-daemon-bpf[bot] wants to merge 1 commit into
Conversation
Author
|
Upstream branch: 7cbd0c4 |
d66fa53 to
b9f68cc
Compare
emit_ia32_div_mod_r() always emits an unsigned divide (xor edx,edx + div ecx), regardless of the BPF instruction's signedness. Signed ALU32 BPF_DIV and BPF_MOD (off=1) therefore get an unsigned quotient and remainder in the i386 JIT, diverging from the verifier's and the interpreter's signed result for negative operands. Thread is_signed = (insn->off == 1) into emit_ia32_div_mod_r() and emit cdq + idiv ecx on the signed path, xor edx,edx + div ecx unchanged on the unsigned path, mirroring the cdq/idiv-vs-xor/div split the x86_64 JIT uses for the same instructions. bpf_do_misc_fixups() rewrites the zero-divisor and INT_MIN/-1 cases out of the instruction stream before the JIT runs. The RV32 JIT has the same gap. Fixes: ec0e2da ("bpf: Support new signed div/mod instructions.") Signed-off-by: Nicholas Dudar <main.kalliope@gmail.com> Assisted-by: Claude:claude-opus-4-8
Author
|
Upstream branch: 71836d0 |
e5ae137 to
19a3f0f
Compare
Author
|
At least one diff in series https://patchwork.kernel.org/project/netdevbpf/list/?series=1126868 expired. Closing PR. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull request for series with
subject: bpf, x86: Fix signed 32-bit div/mod in the i386 JIT
version: 1
url: https://patchwork.kernel.org/project/netdevbpf/list/?series=1126868